<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>自定义指令</title>
</head>
<body>

<div id="app">
  <label>
    <input type="text" v-color="{color: 'orange'}">
  </label>
</div>

<script src="../lib/vue.js"></script>
<script>
  /**
   * 用Vue.directive来自定义指令
   */
  Vue.directive('color', {
    // el表示指令绑定的元素
    bind(el, binding) {
      console.log(el, binding)
      el.style.backgroundColor = binding.value.color
    }
  })

  let vm = new Vue({
    el: '#app',
    data: {
      msg: 'Hello World'
    }
  })
</script>

</body>
</html>